home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / AboutDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-02-03  |  2.6 KB  |  68 lines

  1. import java.awt.Button;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dialog;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.Frame;
  9. import java.awt.Label;
  10. import java.awt.LayoutManager;
  11. import java.awt.Rectangle;
  12.  
  13. public class AboutDialog extends Dialog {
  14.    Button okButton;
  15.    Label labelAbout;
  16.  
  17.    void okButton_Clicked(Event event) {
  18.       ((Component)this).hide();
  19.    }
  20.  
  21.    public AboutDialog(Frame parent, boolean modal) {
  22.       super(parent, modal);
  23.       ((Container)this).setLayout((LayoutManager)null);
  24.       ((Dialog)this).addNotify();
  25.       ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 335, ((Container)this).insets().top + ((Container)this).insets().bottom + 86);
  26.       ((Component)this).setFont(new Font("Dialog", 1, 12));
  27.       ((Component)this).setForeground(new Color(0));
  28.       ((Component)this).setBackground(new Color(16777215));
  29.       this.okButton = new Button("OK");
  30.       this.okButton.reshape(((Container)this).insets().left + 128, ((Container)this).insets().top + 48, 72, 26);
  31.       this.okButton.setFont(new Font("Dialog", 1, 12));
  32.       ((Container)this).add(this.okButton);
  33.       this.labelAbout = new Label("Amazing Adventures Travel - Custom Itinerary Application");
  34.       this.labelAbout.reshape(((Container)this).insets().left + -8, ((Container)this).insets().top + 8, 344, 31);
  35.       this.labelAbout.setFont(new Font("Dialog", 1, 12));
  36.       this.labelAbout.setForeground(new Color(0));
  37.       this.labelAbout.setBackground(new Color(16777215));
  38.       ((Container)this).add(this.labelAbout);
  39.       ((Dialog)this).setTitle("About");
  40.       ((Dialog)this).setResizable(false);
  41.    }
  42.  
  43.    public AboutDialog(Frame parent, String title, boolean modal) {
  44.       this(parent, modal);
  45.       ((Dialog)this).setTitle(title);
  46.    }
  47.  
  48.    public synchronized void show() {
  49.       Rectangle bounds = ((Component)this).getParent().bounds();
  50.       Rectangle abounds = ((Component)this).bounds();
  51.       ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
  52.       super.show();
  53.    }
  54.  
  55.    public boolean handleEvent(Event event) {
  56.       if (event.id == 201) {
  57.          ((Component)this).hide();
  58.          return true;
  59.       } else {
  60.          if (event.target == this.okButton && event.id == 1001) {
  61.             this.okButton_Clicked(event);
  62.          }
  63.  
  64.          return super.handleEvent(event);
  65.       }
  66.    }
  67. }
  68.